package com.tianji.tjpromotion.mapper;

import com.tianji.tjpromotion.domain.po.Coupon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 优惠券的规则信息 Mapper 接口
 * </p>
 *
 * @author yp
 * @since 2024-08-02
 */
public interface CouponMapper extends BaseMapper<Coupon> {


    //    @Update("update coupon  set issue_num = issue_num +1 where id = #{id} and issue_num = #{issueNum}")
//    int incrIssueNum(@Param("id")Long id ,@Param("issueNum") int issueNum);
    @Update("update coupon  set issue_num = issue_num +1 where id = #{id} and issue_num < total_num")
    //数据库行锁
    int incrIssueNum(@Param("id") Long id);
}
